import Vue from 'vue'
import Router from 'vue-router'
import AuthService from '../_ddd/auth.service'
import TianDingIndexComponent from '@/modules'
import TianDingSelectComponent from '@/modules/select'
import TianDingLoginComponent from '@/modules/login'
import TianDingRegisteredComponent from '@/modules/registered'
import TianDingForgetComponent from '@/modules/forget'
import TianDingCodeComponent from '@/modules/wx/code.vue'
import TianDingPaySuccessComponent from '@/modules/wx/paySuccess.vue'
import TianDingStatusComponent from '@/modules/status.vue'
import TianDingClearComponent from '@/modules/clear.vue'


import PatientRouter from './patient'
import DoctorRouter from './doctor'

Vue.use(Router)

let routes = [{
        path: '/',
        name: 'tdIndex',
        component: TianDingIndexComponent
    },
    {
        path: '/tdIndex',
        name: 'tdIndex',
        component: TianDingIndexComponent
    },
    {
        path: '/tdSelect',
        name: 'tdSelect',
        component: TianDingSelectComponent
    },
    {
        path: '/tdLogin',
        name: 'tdLogin',
        component: TianDingLoginComponent,
        meta: {
            title: "登录"
        }
    },
    {
        path: '/tdRegistered',
        name: 'tdRegistered',
        component: TianDingRegisteredComponent,
        meta: {
            title: "注册"
        }
    },
    {
        path: '/tdForget',
        name: 'tdForget',
        component: TianDingForgetComponent,
        meta: {
            title: "忘记密码"
        }
    },
    {
        path: '/tdCode',
        name: 'tdCode',
        component: TianDingCodeComponent,
        meta: {
            title: "获取code"
        }
    },
    {
        path: '/tdPaySuccess',
        name: 'tdPaySuccess',
        component: TianDingPaySuccessComponent,
        meta: {
            title: "支付成功"
        }
    },
    {
        path: '/tdStatus',
        name: 'tdStatus',
        component: TianDingStatusComponent,
        meta: {
            title: "快速登录"
        }
    },
    {
        path: '/adClear',
        name: 'adClear',
        component: TianDingClearComponent,
        meta: {
            title: "清除缓存"
        }
    },
    ...PatientRouter,
    ...DoctorRouter
];

const router = new Router({
    mode: 'history',
    routes: routes
});

AuthService.tokenAuth(Vue, router, routes);

export default router;